package com.zksk.admin.mapper.customer;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zksk.mbg.admin.domain.RRateCustomerReq;
import com.zksk.mbg.admin.domain.Rate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 客户（平台）对产品的要求与费率关系表 Mapper 接口
 * </p>
 *
 * @author Zksk Acmen
 * @since 2022-12-07
 */
@Mapper
public interface RRateCustomerReqDao extends BaseMapper<RRateCustomerReq>
{

    @Select("SELECT\n" +
            "\tr.id,\n" +
            "\tr.type,\n" +
            "\tr.cost_ratio,\n" +
            "\tr.min_pay_num,\n" +
            "\tr.desc \n" +
            "FROM\n" +
            "\tplatform_rate AS r\n" +
            "\tINNER JOIN \n" +
            "\t(\n" +
            "\t\tSELECT\n" +
            "\t\t\trate_id \n" +
            "\t\tFROM\n" +
            "\t\t\tplatform_r_rate_customer_req \n" +
            "\t\tWHERE\n" +
            "\t\t\tcustomer_prod_req_id = #{id}\n" +
            "\t) AS i\n" +
            "WHERE\n" +
            "\tr.id = i.rate_id\n" +
            "AND\n" +
            "\tr.del_flag = 0")
    List<Rate> selectRateList(Long id);

}
